<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Private extends Controller_Template {
	
	public function __construct($request, $response){
		parent::__construct($request, $response);
		$this->auto_render = FALSE;
	}
	
	public function before(){
		parent::before();
	}
	
	public function after(){
		parent::after();
	}
	
	public function action_index()
	{
		var_dump($this->auto_render);
	}
	
	public function action_action(){
		$this->ajax->fail('参数不正确')->json();
		if (($post = $this->post) && ($id = $post['what'])){
			switch ($post['how']){
				case 'del':
					$result = MYSQL::factory($post['where'],$id)->delete()->exec();
					if ($result) $this->ajax->success('删除成功');
					break;
				case 'position':
					$result = lib_position::factory($post['where'],$id)->{$post['direction']}();
					if ($result) $this->ajax->success('排序成功');
					else $this->ajax->fail(lib_message::get());
					break;
				default:{$this->ajax->fail('没有找到处理方法');}
			}
		}
	}

	public function action_comments(){
		/*if (($post = $this->post) && lib_validate::need($post, array('_id','name','content'))){
			MON::factory('comment')->insert(array(
				'article_id'=>new MongoId($post['_id']),
				'rewrite'=>$post['rewrite'],
				'name'=>$post['name'],
				'content'=>$post['content'],
				'ip'=>common::getip(),
				'addTime'=>time()
			));
			
			if ($article = MON::factory('article',$post['_id'])){
				$smarty = m::factory('smarty');
				$smarty->clearCache('a.tpl',md5($article['rewrite']));
				$smarty->clearCache('index.tpl',md5($article['rewrite']));
			}
		}*/
		lib_url::redirect($this->referer);
	}
} // End Welcome
